/****************************************************************************************
 * 文件名  ：osal_main.c
 * 描述    ：osal操作系统运行主函数，添加任务在此文件中添加
 * 开发平台：STM8S003F3
 * 库版本  ：无
 ***************************************************************************************/
#include "application.h"

#include "GPIO.h"
#include "RS485.h"
#include "TIM1_PWM.h"
#include "app_Task.h"

static void CLK_Config(void)
{
    /* Initialization of the clock */
    /* Clock divider to HSI/1 */
	/*!< High speed internal clock prescaler: 1 */
/* 	Configure system clock to run at 16Mhz*/ 
	CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
	CLK_HSICmd(ENABLE);
}
static void HardwareInit()
{
 	CLK_Config();
	GPIO_Config();
	// UART_Config();
	TIM1_Config();
	Check_TIM1_CH1CH2_OptionByte();


}


void main(void)
{    
	//系统硬件、外设等初始化
	HardwareInit();

	//禁止中断
    HAL_DISABLE_INTERRUPTS();

    //osal操作系统初始化
    osal_init_system();

	//添加任务
	osal_add_Task(Serial_Task_Init,RS485_Task_EventProcess,1);	
	//添加的任务统一进行初始化
	osal_Task_init();
    
	osal_mem_kick();

	//允许中断
	HAL_ENABLE_INTERRUPTS();	

	//设置初始任务事件，上电就需要自动轮询的任务事件可在此添加
	// osal_start_reload_timer(Serial_TaskID,LED_FLICKER,1000);

	//启动osal系统，不会再返回
	osal_start_system();
}
#ifdef USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param file: pointer to the source file name
  * @param line: assert_param error line source number
  * @retval : None
  */
void assert_failed(u8* file, u32 line)
{ 
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif
